API: Add API to set style properties to be inherit
authorBenjamin Otte <otte@redhat.com>
Mon, 16 May 2011 17:31:47 +0000 (19:31 +0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 18 May 2011 20:17:57 +0000 (22:17 +0200)
The API is not used anywhere yet.

docs/reference/gtk/gtk3-sections.txt
gtk/gtk.symbols
gtk/gtkstyleproperties.c
gtk/gtkstyleproperties.h

index 242e582576249ada1700daf59fed87328184db9b..291b219f78b7c7f63b6a2651950f5863d9df4f7d 100644 (file)
@@ -5487,6 +5487,8 @@ gtk_style_properties_map_color
 gtk_style_properties_merge
 gtk_style_properties_new
 GtkStylePropertyParser
+gtk_style_param_set_inherit
+gtk_style_param_get_inherit
 gtk_style_properties_register_property
 gtk_style_properties_set
 gtk_style_properties_set_property
index ee492ff1c956474977d46bbde2e8db4952b77dc6..88e2e7afb99bea8f9d56026c6f0c0816bd878cdb 100644 (file)
@@ -2520,6 +2520,8 @@ gtk_style_has_context
 gtk_style_lookup_color
 gtk_style_lookup_icon_set
 gtk_style_new
+gtk_style_param_get_inherit
+gtk_style_param_set_inherit
 gtk_style_properties_clear
 gtk_style_properties_get
 gtk_style_properties_get_property
index 38ededc295ee0b5ceacf1c9c73223894bf8ee681..28c2d9a794871c000cb3dc973372fb3138b18274 100644 (file)
@@ -523,6 +523,54 @@ gtk_style_properties_lookup_property (const gchar             *property_name,
   return found;
 }
 
+/* GParamSpec functionality */
+
+enum {
+  GTK_STYLE_PROPERTY_INHERIT = 1 << G_PARAM_USER_SHIFT
+};
+
+/**
+ * gtk_style_param_set_inherit:
+ * @pspec: A style param
+ * @inherit: whether the @pspec value should be inherited
+ *
+ * Sets whether a param spec installed with function such as
+ * gtk_style_properties_register_property() or
+ * gtk_widget_class_install_style_property() should inherit their
+ * value from the parent widget if it is not set instead of using
+ * the default value of @pspec. See the
+ * <ulink url="http://www.w3.org/TR/CSS21/cascade.html#inheritance">
+ * CSS specification's description of inheritance</ulink> for a
+ * longer description of this concept.
+ *
+ * By default, param specs do not inherit their value.
+ **/
+void
+gtk_style_param_set_inherit (GParamSpec *pspec,
+                             gboolean    inherit)
+{
+  if (inherit)
+    pspec->flags |= GTK_STYLE_PROPERTY_INHERIT;
+  else
+    pspec->flags &= ~GTK_STYLE_PROPERTY_INHERIT;
+}
+
+/**
+ * gtk_style_param_get_inherit:
+ * @pspec: a style param
+ *
+ * Checks if the value of this param should be inherited from the parent
+ * #GtkWidget instead of using the default value when it has not been
+ * specified. See gtk_style_param_set_inherit() for more details.
+ *
+ * Returns: %TRUE if the param should inherit its value
+ **/
+gboolean
+gtk_style_param_get_inherit (GParamSpec *pspec)
+{
+  return (pspec->flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE;
+}
+
 /* GtkStyleProperties methods */
 
 /**
index 0cc478892b56e443c84bd56b11e1d2dd4c8ed99e..a38905e050bfc25535e08a67833b881fcbc7b208 100644 (file)
@@ -66,6 +66,10 @@ typedef gboolean (* GtkStylePropertyParser) (const gchar  *string,
 
 GType gtk_style_properties_get_type (void) G_GNUC_CONST;
 
+void     gtk_style_param_set_inherit            (GParamSpec             *pspec,
+                                                 gboolean                inherit);
+gboolean gtk_style_param_get_inherit            (GParamSpec             *pspec);
+
 /* Functions to register style properties */
 void     gtk_style_properties_register_property (GtkStylePropertyParser  parse_func,
                                                  GParamSpec             *pspec);